# 引入协程模块
import asyncio

async def func1():  # 定义协程函数
    print(1)
    await asyncio.sleep(1)
    print(2)

async def func2():
    print(3)
    await asyncio.sleep(2)
    print(4)

if __name__ == '__main__':
    # tasks = [
    #     asyncio.ensure_future(func1()),
    #     asyncio.ensure_future(func2())
    # ]
    # loop = asyncio.get_event_loop() # 生成事件循环
    # loop.run_until_complete(asyncio.wait(tasks))
    task = [func1(), func2()]
    asyncio.run(asyncio.wait(task))
    